import http, {token} from './http.js'
import {
	HOT_SEARCHING_URL,
	KEY_WORD_TIPS_URL,
	SEARCH_WORD_RESULT_URL
} from './url.js'

const getHotSearching = () => {
	return http({
		method: 'post',
		url: HOT_SEARCHING_URL,
		data: {
			"appId": 1005,
			"apiVersion": "5.0",
			"isShowLoading": true,
			"userToken": token,
			"data": {
				"storeNo": "133"
			}
		}
	}).then(res => {
		return res
	}).catch(err => {
		console.log('getHotSearching-err---', err)
	})
}

const getKeyWordTips = (keyword) => {
	return http({
		method: 'post',
		url: KEY_WORD_TIPS_URL,
		data: {
			"appId": 1005,
			"apiVersion": "5.0",
			"userToken": token,
			"data": {
				"storeNo": "133",
				"keyword": keyword //"爱仕达"
			}
		}
	}).then(res => {
		return res
	}).catch(err => {
		console.log('getKeyWordTips-err---', err)
	})
}

const getSearchWordResult = (keyword, page=1) => {
	return http({
		method: 'post',
		url: SEARCH_WORD_RESULT_URL,
		data: {
			"appId": 1005,
			"apiVersion": "5.0",
			"isShowLoading": true,
			"userToken": token,
			"data": {
				"storeNo": "133",
				"keyword": keyword, //"爱仕达",
				"pageSize": 10,
				"page": page
			}
		}
	}).then(res => {
		return res
	}).catch(err => {
		console.log('getSearchWordResult-err---', err)
	})
}

export {getHotSearching, getKeyWordTips, getSearchWordResult}